import {Component, OnInit} from '@angular/core';
import {HttpClient} from '@angular/common/http';
import {generatePageInfo, PageInfo} from '../../util';

@Component({
  selector: 'app-news-list',
  templateUrl: './news-list.component.html',
  styleUrls: ['./news-list.component.css']
})
export class NewsListComponent implements OnInit {

  pageInfo: PageInfo = new PageInfo();

  constructor(private http: HttpClient) {
    this.http.get('/news/list', {observe: 'response'}).subscribe(result => {
      generatePageInfo(this.pageInfo, result);
    });
  }

  ngOnInit() {
  }
  changePage(page: number) {
    this.http.get('/news/list?page=' + page).subscribe(result => this.pageInfo.data = result);
  }
}
